API Documentation
Public Member Functions | List of all members
nkResources::ResourceManager Class Referencefinal

Manager helping with path finding and resource loading. More...

Inheritance diagram for nkResources::ResourceManager:

Public Member Functions

void setWorkingPath (const nkMemory::StringView &path)
 
void setWorkingPathAbsolute (const nkMemory::StringView &path)
 
nkMemory::String getWorkingPath () const
 
nkMemory::String getWorkingPathAbsolute () const
 
nkMemory::String getLaunchedPath () const
 
void setLaunchedPath (const nkMemory::StringView &path)
 
nkMemory::String getRelativeFromAbsolute (const nkMemory::StringView &absolutePath) const
 
nkMemory::String getAbsoluteFromRelative (const nkMemory::StringView &relativePath) const
 
nkMemory::String getRelativeFromWorkingDir (const nkMemory::StringView &workingPath) const
 
nkMemory::String getAbsoluteFromWorkingDir (const nkMemory::StringView &workingPath) const
 
nkMemory::String getFromWorkingDirFromRelative (const nkMemory::StringView &relativePath) const
 
nkMemory::String getFromWorkingDirFromAbsolute (const nkMemory::StringView &absolutePath) const
 
bool checkFileExists (const nkMemory::StringView &filePathAbs) const
 
void checkFolderExists (nkMemory::String path)
 
nkMemory::Buffer loadFileIntoMemory (const nkMemory::StringView &filePathAbs, bool silent=false)
 

Detailed Description

Manager helping with path finding and resource loading.

It uses 3 keywords for all paths it manipulates :

Transformations from one path to another use these keywords :

Member Function Documentation

◆ setWorkingPath()

void nkResources::ResourceManager::setWorkingPath ( const nkMemory::StringView path)

Sets the working path.

Parameters
pathThe path of the wanted path, relative to the path from where the software is launched.

◆ setWorkingPathAbsolute()

void nkResources::ResourceManager::setWorkingPathAbsolute ( const nkMemory::StringView path)

Sets the working path.

Parameters
pathThe path of the wanted path, absolute.

◆ getWorkingPath()

nkMemory::String nkResources::ResourceManager::getWorkingPath ( ) const
Returns
The current set working path, as a path relative to the path from where the software is launched.

◆ getWorkingPathAbsolute()

nkMemory::String nkResources::ResourceManager::getWorkingPathAbsolute ( ) const
Returns
The current set working path, absolute.

◆ getLaunchedPath()

nkMemory::String nkResources::ResourceManager::getLaunchedPath ( ) const
Returns
The path from where the program was launched.

◆ setLaunchedPath()

void nkResources::ResourceManager::setLaunchedPath ( const nkMemory::StringView path)

Allows to override the path from which the program is launched.

Remarks
This path is already populated by default by the ResourceManager. Call this function only if you really need to.

◆ getRelativeFromAbsolute()

nkMemory::String nkResources::ResourceManager::getRelativeFromAbsolute ( const nkMemory::StringView absolutePath) const

Converts a path, from absolute, to a path relative to the launched path.

Parameters
absolutePathThe absolute path to convert.
Returns
The path converted.

◆ getAbsoluteFromRelative()

nkMemory::String nkResources::ResourceManager::getAbsoluteFromRelative ( const nkMemory::StringView relativePath) const

Converts a path, from relative to the launched directory, to absolute.

Parameters
relativePathThe relative path to convert.
Returns
The path converted.

◆ getRelativeFromWorkingDir()

nkMemory::String nkResources::ResourceManager::getRelativeFromWorkingDir ( const nkMemory::StringView workingPath) const

Converts a path, from relative to the working directory, to relative to the launched path.

Parameters
workingPathThe path relative to the working directoy to convert.
Returns
The path converted.

◆ getAbsoluteFromWorkingDir()

nkMemory::String nkResources::ResourceManager::getAbsoluteFromWorkingDir ( const nkMemory::StringView workingPath) const

Converts a path, from relative to the working directory, to absolute.

Parameters
workingPathThe path relative to the working directoy to convert.
Returns
The path converted.

◆ getFromWorkingDirFromRelative()

nkMemory::String nkResources::ResourceManager::getFromWorkingDirFromRelative ( const nkMemory::StringView relativePath) const

Converts a path, from relative to the launched directory, to relative to the working directory.

Parameters
relativePathThe path relative to the launched path to convert.
Returns
The path converted.

◆ getFromWorkingDirFromAbsolute()

nkMemory::String nkResources::ResourceManager::getFromWorkingDirFromAbsolute ( const nkMemory::StringView absolutePath) const

Converts a path, from absolute, to relative to the working directory.

Parameters
absolutePathThe absolute path to convert.
Returns
The path converted.

◆ checkFileExists()

bool nkResources::ResourceManager::checkFileExists ( const nkMemory::StringView filePathAbs) const

Checks if a file exists for a certain path.

Parameters
filePathAbsThe absolute path to check.
Returns
True if the file exists, false otherwise.

◆ checkFolderExists()

void nkResources::ResourceManager::checkFolderExists ( nkMemory::String  path)

Checks if a folder exists for a certain path.

Parameters
pathThe absolute path to check.
Returns
True if the file exists, false otherwise.

◆ loadFileIntoMemory()

nkMemory::Buffer nkResources::ResourceManager::loadFileIntoMemory ( const nkMemory::StringView filePathAbs,
bool  silent = false 
)

Loads a file into memory.

Parameters
filePathAbsThe path to the file, absolute.
silentIf a failure in finding the requested file should not be logged. True for no logging, false otherwise.
Returns
A binary buffer holding the file data.

The documentation for this class was generated from the following file: